package com.coda.controller.user;

import com.coda.common.Result;
import com.coda.context.BaseContext;
import com.coda.pojo.Statistics;
import com.coda.pojo.User;
import com.coda.pojo.Word;
import com.coda.pojo.vo.BeforeSevenDaysDictationVo;
import com.coda.pojo.vo.UserRankVo;
import com.coda.pojo.vo.UserWordVo;
import com.coda.pojo.vo.WordGardAndStatusVo;
import com.coda.service.StatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 统计数据controller
 */
@RestController
@RequestMapping("/user/statistics")
public class StatisticsController {

    @Autowired
    private StatisticsService statisticsService;

    /**
     * 当前用户已经默写单词统计
     */
    @GetMapping()
    public Result<Statistics> getWordStatistics() {
        Statistics statistics = statisticsService.getWordStatistics(BaseContext.getCurrentId());
        return Result.success(statistics);
    }

    /**
     * 最近一周的默写统计
     */
    @GetMapping("/getWeekWordCount")
    public Result<List<BeforeSevenDaysDictationVo>> getBeforeWeek(){
        List<BeforeSevenDaysDictationVo> list = statisticsService.getBeforeWeek();
        return Result.success(list);
    }

    /**
     * 查询所有单词难度等级
     */
    @GetMapping("/gard")
    public Result<WordGardAndStatusVo> getGardAndStatusCount() {
        WordGardAndStatusVo wordGardAndStatusVo = statisticsService.getGardAndStatusCount();
        return Result.success(wordGardAndStatusVo);
    }

    /**
     * 获取前单词默写数量前六名的用户排名
     */
    @GetMapping("/userRank")
    public Result<List<UserRankVo>> getUserRank() {
        List<UserRankVo> list = statisticsService.getUserRank();
        return Result.success(list);
    }

    /**
     * 获取当前用户错误次数最多的20个单词
     */
    @GetMapping("/incorrectCount")
    public Result<List<Word>> getIncorrectCount() {
        List<Word> wordList = statisticsService.getIncorrectCount();
        return  Result.success(wordList);
    }



}
